"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
//  接口
// 方法对于json对象的约束
function printLabel(labelInfo) {
    return labelInfo.label;
}
console.log(printLabel({ 'label': '帅哥' }));
function printName(name) {
    if (name.age) {
        return name.firstName + "---" + name.secondName + "---" + name.age;
    }
    else {
        return name.firstName + name.secondName;
    }
}
// 在外部定义对象传入 只要含有firstName和secondName 可以含有其他属性
var obj = {
    firstName: "尼古拉斯",
    secondName: "赵四",
    age: 21
};
//这样直接传入对象 需要只能包含firstName和secondName 不能包含其他属性
console.log(printName({ firstName: '尼古拉斯', secondName: '二狗' }));
console.log(printName(obj));
function ajax(config) {
    var xhr = new XMLHttpRequest();
    xhr.open(config.type, config.url, true);
    xhr.send(config.data);
    console.log(config.data);
    xhr.onreadystatechange = function () {
        //console.log(xhr.responseText)
        if (xhr.readyState == 4 && xhr.status == 200) {
            console.log('success');
        }
        if (config.dataType === 'json') {
            JSON.parse(xhr.responseText);
        }
        else {
            console.log(xhr.responseText);
        }
    };
}
var conf = {
    type: 'get',
    url: 'https://www.mxnzp.com/api/image/girl/list/random',
    dataType: 'json'
};
ajax(conf);
var md5 = function (key1, value1) {
    return key1 + '---' + value1;
};
console.log(md5('ywj', '最帅'));
var arr1 = ['123', '12'];
console.log(arr1, arr1[0]);
var obj2 = { user: 'ywj', age: '20' };
console.log(obj2);
console.log(obj2.user);
var Dogs = /** @class */ (function () {
    function Dogs(name) {
        this.name = name;
    }
    Dogs.prototype.drink = function (water) {
        return this.name + "\u559D" + water;
    };
    Dogs.prototype.eat = function (food) {
        return this.name + "\u5403" + food;
    };
    return Dogs;
}());
var dogs = new Dogs('xiaoming');
console.log(dogs.eat('狗粮'));
var Your = /** @class */ (function () {
    function Your(str) {
        this.str = str;
    }
    Your.prototype.drink = function (water) {
        return this.str + "\u559D" + water;
    };
    return Your;
}());
//  实现了Persons 需要重写Persons和Animals的方法
//  类可以实现接口和继承父类
var Mine = /** @class */ (function (_super) {
    __extends(Mine, _super);
    function Mine(str, name, age) {
        var _this = _super.call(this, str) || this;
        _this.name = name;
        _this.age = age;
        return _this;
    }
    Mine.prototype.eat = function (food) {
        return this.name + "---" + this.age + "---\u5403" + food;
    };
    Mine.prototype.work = function (job) {
        return this.name + "---" + this.age + "---" + job;
    };
    return Mine;
}(Your));
var mine = new Mine('二狗', 'ywj', 20);
console.log(mine.eat('饭'));
console.log(mine.work('打代码'));
console.log(mine.drink('水'));
